/***************************************************************************
 * Open Object Oriented ANSI C                                             *
 ***************************************************************************
 * Code given under the terms of GNU General Public Licence (GPLv3)        *
 * and without any waranties of any kind including but not limitative to   *
 * waranties on merchandability or any particular applications fitness.    *
 * For more information on GNU/GPL go on :                                 *
 * "http://www.gnu.org/copyleft/gpl.html"                                  *
 *                                                                         *
 * You are allowed to use it for any purposes in the terms of GNU/GPLv3    *
 * (or more).                                                              *
 * This text MUST stay in state on copyed sources (or sources using it)    *
 * and must not be altered.                                                *
 * You are allowed to add your name at the end of the Copylefs list.       *
 ***************************************************************************
 * Copylefts List :                                                        *
 ***************************************************************************
 * 2010-03-20 Patrick PIGNOL <pignol_patrick@hotmail.com> (Original)       *
 * (Type your name here if needed)                                         *
 ***************************************************************************/
#ifndef EXCEPTIONSTATERECOVER_H_INCLUDED
#define EXCEPTIONSTATERECOVER_H_INCLUDED

#define EXCEPTIONSTATERECOVER_TYPEID 4

typedef struct ExceptionStateRecoverVirtualTable ExceptionStateRecoverVirtualTable;
typedef struct ExceptionStateRecover ExceptionStateRecover;

#include <setjmp.h>
#include "Stack.h"
#include "ExceptionHandler.h"


struct ExceptionStateRecoverVirtualTable
{
    unsigned long int TypeID;
    ClassInterface* Interface;
    ClassVirtualTable* AncestorTable;
    unsigned long int ReferenceCount;
    ExceptionStateRecover* (*new)(unsigned long int pArgsCount, va_list* pParameters);
    ExceptionStateRecoverVirtualTable* (*Initialize)(ExceptionStateRecover* this, unsigned long int pArgsCount, va_list* pParameters);
    void (*Garbage)(ExceptionStateRecover* this);
    unsigned long int (*TypeOf)(ExceptionStateRecover* this);
    bool (*IsSameTypeThanTypeID)(ExceptionStateRecover* this, unsigned long int pTypeID);
    bool (*IsKindOfTypeID)(ExceptionStateRecover* this, unsigned long int pTypeID);
    bool (*IsSameTypeThan)(ExceptionStateRecover* this, Class* pSource);
    bool (*IsKindOf)(ExceptionStateRecover* this, Class* pSource);
};

struct ExceptionStateRecover
{
    ExceptionStateRecoverVirtualTable* VirtualTable;
    void (*Constructor)(ExceptionStateRecover* this, unsigned long int pArgsCount, va_list* pParameters); /* Constructor pointer of object. Called by Initialise(). Must be propagated on inherited that do not override.*/
    void (*Destructor)(ExceptionStateRecover* this); /* Destructor pointer of object. Called by Garbage(). Must be propagated on inherited that do not override.*/
    ExceptionStateRecover* (*Clone)(ExceptionStateRecover* this);
    jmp_buf aSafeState;   /* PRIVATE /// */
    Stack* aExceptionHandlers; /* PRIVATE /// */
    jmp_buf* (*SafeState)(ExceptionStateRecover* this);
    const Stack* (*ExceptionHandlers)(ExceptionStateRecover* this);
};

ExceptionStateRecover* ExceptionStateRecoverNew(unsigned long int pArgsCount, va_list* pParameters);
ExceptionStateRecoverVirtualTable* ExceptionStateRecoverInitialize(ExceptionStateRecover* this, unsigned long int pArgsCount, va_list* pParameters); /* Called by new method to create object in heap memory. Must be propagated on inherited that do not override.*/
void ExceptionStateRecoverConstructor(ExceptionStateRecover* this, unsigned long int pArgsCount, va_list* pParameters); /* Constructor pointer of object. Called by Initialise(). Must be propagated on inherited that do not override.*/
void ExceptionStateRecoverDestructor(ExceptionStateRecover* this); /* Destructor pointer of object. Called by Garbage(). Must be propagated on inherited that do not override.*/
ExceptionStateRecover* ExceptionStateRecoverClone(ExceptionStateRecover* this);
jmp_buf* ExceptionStateRecoverSafeState(ExceptionStateRecover* this);
const Stack* ExceptionStateRecoverExceptionHandlers(ExceptionStateRecover* this);

#endif /* EXCEPTIONSTATERECOVER_H_INCLUDED*/
